package cn.com.nes.site.service.comecall.impl;

import cn.com.nes.mybatis.callcenter.mapper.CallExtensionMapper;
import cn.com.nes.site.entity.vo.comecall.CallExtensionVO;
import cn.com.nes.site.service.comecall.CallExtensionService;
import cn.com.nes.site.service.comecall.dto.CallExtensionDto;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class CallExtensionServiceImpl implements CallExtensionService {

    @Resource
    private CallExtensionMapper callExtensionMapper;

    @Override
    public int bindExtension(CallExtensionVO vo) {
       return callExtensionMapper.updateBycallExtension(vo);
    }

    @Override
    public int unBindExtension(CallExtensionVO vo) {
        return callExtensionMapper.updateBycallExtension(vo);
    }

    @Override
    public Page<CallExtensionDto> getExtensions(CallExtensionVO vo) {
        if (vo == null || vo.getCompanyAttachId() == null ) {
            return null;
        }
        Page<CallExtensionDto> page = new Page<>(vo.getPageid(), vo.getPagesize());
        List<CallExtensionDto> res = callExtensionMapper.getExtensions(page,vo.getCompanyAttachId());
        return page.setRecords(res) ;
    }

}
